<template>
	<uni-list>
		<!-- title、note设置标题和小文字 -->
		<uni-list-item clickable direction="row" v-for="item in listData" :key="item.id" :title="item.indexName"
			@click="gotoContent(item)">
		</uni-list-item>
		<page-tabpars></page-tabpars>
	</uni-list>
</template>

<script>
	// 读取json文件
	import mockData from './mock.json';
	export default {
		data() {
			return {
				listData: [],
				name: '你好'
			}
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			 //打印出上个页面传递的参数。
			this.name=option.bookname;
			uni.setNavigationBarTitle({
				title: option.bookname
			})
			this.$myRequist({
				url: '/book/queryIndexList?bookid=' + option.bookid
			}).then(res => {
				this.listData = res.data.rows;
			});
		},
		// created() {
		// 	let result=mockData.rows;
		// 	this.listData=result;
		// },
		methods: {
			gotoContent(item) {
				uni.navigateTo({
					url: '/pages/book/bookContent/bookContent?bookName=' 
					+ this.name+'&bookId='+item.bookId+'&indexNum='+item.indexNum
				});
			}
		}
	}
</script>

<style>
	.image-1 {
		flex-shrink: 0;
		margin-right: 10px;
		width: 50px;
		height: 75px;
		border-radius: 6px;
		overflow: hidden;
		border: 1px #f5f5f5 solid;
	}
</style>
